package Operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created by Salted fish
 * Description:
 * User: 24539
 * Date：2021-09-22
 * Time: 15:48
 */
public class ReturnOperation  implements Opface{
    @Override
    public void work(BookList bookList) {
        System.out.println("归还图书");
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入归还图书的名字： ");
        String name = scanner.next();
        int size = bookList.getUsedSize();
        for(int i = 0; i<size;i++) {
            Book book1 = bookList.getBook(i);
            if(book1.getName().equals(name)) {
                book1.setBoroowed(false);
                System.out.println("归还成功");
                return;
            }
        }
        System.out.println("归还失败");
    }
}
